<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加商品</title>
</head>
<body>
<form enctype="multipart/form-data" id="form">
	<div>
		<div>
			<lable>商品名字：</lable>
			<input type="text" name="name" id="name" placeholder="请输入商品名称。。。">
		</div>
		<div>
			<lable>商品价格：</lable>
			<input type="text" name="price" id="price" placeholder="清输入商品价格。。。">
		</div>
		<div>
			<lable>商品图片：</lable>
			<input type="file" name="pic" id="pic">
		</div>
		<div>
			<input type="button" value="添加商品" class="active">
		</div>
	</div>
</form>
<script src="/static/news/js/jquery-1.12.4.min.js"></script>
<script>
	$(".active").click(function () {
	    formdata = new FormData($("#form")[0]);
		$.ajax({
			url:"/page",
			method:"post",
			data:formdata,
			processData:false,
			contentType:false,
			success:function (data) {
				alert(data.msg);
				console.log(data);
				{#window.location.href="/page";#}
            },
			error:function (error,data) {
				alert(data.msg);
				console.log(error)
            },
		})
    })
</script>
</body>
</html>